package org.course.SFtesting;

public class wholesaleCompany {

	String name;
	public wholesaleCompany(String companyName) {
		this.name = companyName;
	}
	public String getName() {
		return name;
	}
	public double percentage(int numberBought, int unitPrice) throws IllegalnumberBoughtException,IllegalunitPriceException{
		double money = 0.0;
		if(1 <= numberBought && numberBought <= 9){
			if(1 <= unitPrice && unitPrice <= 10){
				money = unitPrice;
			}
			else if(11 <= unitPrice && unitPrice <= 100){
				money = (unitPrice * 0.95);
			}
			else if(101 <= unitPrice){
				money = (unitPrice * 0.9);
			}
			else{
				throw new IllegalunitPriceException();
			}
		}
		else if(10 <= numberBought && numberBought <= 49){
			if(1 <= unitPrice && unitPrice <= 10){
				money = (unitPrice * 0.9);
			}
			else if(11 <= unitPrice && unitPrice <= 100){
				money = (unitPrice * 0.85);
			}
			else if(101 <= unitPrice){
				money = (unitPrice * 0.8);
			}
			else{
				throw new IllegalunitPriceException();
			}
		}
		else if(50 <= numberBought){
			if(1 <= unitPrice && unitPrice <= 10){
				money = (unitPrice * 0.8);				
			}
			else if(11 <= unitPrice && unitPrice <= 100){
				money = (unitPrice * 0.75);
			}
			else if(101 <= unitPrice){
				money = (unitPrice * 0.7);				
			}
			else{
				throw new IllegalunitPriceException();
			}
		}
		else{
			throw new IllegalnumberBoughtException();
		}
		return money;
	}

}
